package models.pubobj;

import models.application.AniApp;
import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import java.util.List;

/**
 * User: yeqingzhou
 * Date: 12-8-30
 */
@Entity
public class AniObjectType extends Model {
	
	public enum ObjectTypes {
		PUBLIC,
		PROTECTED,
		PRIVATE
	}
	
    @Id
    public Long id;
    
    public String typeKey;

    public AniObjectType(String typeKey) {
        this.typeKey = typeKey;
    }

    public AniObjectType(Long id) {
        this.id = id;
    }

    // -- Queries

    public static Model.Finder<Long, AniObjectType> find = new Finder<Long, AniObjectType>(Long.class, AniObjectType.class);

    public static List<AniObjectType> findAll() {
    	List<AniObjectType> allTypes = find.all();
        return allTypes;
    }

    public static AniObjectType findByTypeKey(String typeKey) {
        return find.where().eq("typeKey", typeKey).findUnique();
    }

    public static AniObjectType findById(Long objTypeId){
        return find.byId(objTypeId);
    }

}
